package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TMake;
import com.ruoyi.system.service.ITMakeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 挂号信息Controller
 * 
 * @author ruoyi
 * @date 2021-03-25
 */
@RestController
@RequestMapping("/system/make")
public class TMakeController extends BaseController
{
    @Autowired
    private ITMakeService tMakeService;

    /**
     * 查询挂号信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:make:list')")
    @GetMapping("/list")
    public TableDataInfo list(TMake tMake)
    {
        startPage();
        List<TMake> list = tMakeService.selectTMakeList(tMake);
        return getDataTable(list);
    }

    /**
     * 导出挂号信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:make:export')")
    @Log(title = "挂号信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TMake tMake)
    {
        List<TMake> list = tMakeService.selectTMakeList(tMake);
        ExcelUtil<TMake> util = new ExcelUtil<TMake>(TMake.class);
        return util.exportExcel(list, "make");
    }

    /**
     * 获取挂号信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:make:query')")
    @GetMapping(value = "/{mid}")
    public AjaxResult getInfo(@PathVariable("mid") Long mid)
    {
        return AjaxResult.success(tMakeService.selectTMakeById(mid));
    }

    /**
     * 新增挂号信息
     */
    @PreAuthorize("@ss.hasPermi('system:make:add')")
    @Log(title = "挂号信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TMake tMake)
    {
        return toAjax(tMakeService.insertTMake(tMake));
    }

    /**
     * 修改挂号信息
     */
    @PreAuthorize("@ss.hasPermi('system:make:edit')")
    @Log(title = "挂号信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TMake tMake)
    {
        return toAjax(tMakeService.updateTMake(tMake));
    }

    /**
     * 删除挂号信息
     */
    @PreAuthorize("@ss.hasPermi('system:make:remove')")
    @Log(title = "挂号信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mids}")
    public AjaxResult remove(@PathVariable Long[] mids)
    {
        return toAjax(tMakeService.deleteTMakeByIds(mids));
    }
}
